package com.gxa.accommodation.controller;

import com.gxa.accommodation.dto.AccommodationRoomDTO;
import com.gxa.accommodation.dto.SelectRoomByRoomTypeDTO;
import com.gxa.accommodation.service.AccommodationOrderService;
import com.gxa.accommodation.service.AccommodationRoomService;
import com.gxa.common.base.RespResult;
import com.gxa.common.page.AccommodationQueryPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 房间
 */
@RestController
@RequestMapping("/accommodationRoom")
public class AccommodationRoomController {

    @Autowired
    private AccommodationRoomService accommodationRoomService;

    @Autowired
    private AccommodationOrderService orderService;

    /**
     * 添加房间
     * @param accommodationRoomTO
     * @return
     */
    @PostMapping("/addRoom")
    public RespResult addRoom(@Validated @RequestBody AccommodationRoomDTO accommodationRoomTO){
        return accommodationRoomService.addRoom(accommodationRoomTO);
    }

    /**
     * 展示所有房间列表
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping("/showRoomList")
    public RespResult showRoomList(Integer currentPage,Integer pageSize){
        return accommodationRoomService.showRoomList(currentPage,pageSize);
    }

    /**
     * 通过订单号和房间类型查询酒店房间
     * @return
     */
    @GetMapping("/showRoomListByOrderNumAndRoomSerial")
    public RespResult showRoomListByStatusAndAccommodationId(@RequestBody SelectRoomByRoomTypeDTO selectRoomByRoomTypeDTO){
        return accommodationRoomService.showRoomListByOrderNumAndRoomSerial(selectRoomByRoomTypeDTO);
    }

    /**
     * 根据订单安排房间
     */
    @PostMapping("/arrangeRoomByOrder")
    public RespResult arrangeRoomByOrder(Long orderId,Long roomId){
        return accommodationRoomService.arrangeRoomByOrder(orderId,roomId);
    }

    /**
     * 根据订单退住房间
     */
    @PostMapping("/outRoomByOrder")
    public RespResult outRoomByOrder(Long orderId,Long roomId){
        return accommodationRoomService.outRoomByOrder(orderId,roomId);
    }

    /**
     * 退款审核
     */
    @PostMapping("/refundByOrder")
    public RespResult refundByOrder(Long orderId,Byte audit){
        return accommodationRoomService.refundByOrder(orderId,audit);
    }

    /**
     * 根据订单换房房间
     */
    @PostMapping("/changeRoomByOrder")
    public RespResult changeRoomByOrder(Long orderId,Long roomId1,Long roomId2){
        return accommodationRoomService.changeRoomByOrder(orderId,roomId1,roomId2);
    }

    /**
     * 查询所有下单信息
     * @param accommodationQueryPage
     * @return
     */
    @PostMapping("/listAccommodationByQueryPage")
    public RespResult listAccommodationByQueryPage(@RequestBody AccommodationQueryPage accommodationQueryPage){
        return orderService.showOrderList(accommodationQueryPage);
    }


}
